package com.mvcplus.core.freemarker;

import com.mvcplus.common.constant.GlobalConstant;
import com.mvcplus.common.utils.LoggerUtils;
import org.springframework.web.servlet.view.freemarker.FreeMarkerView;

import javax.servlet.http.HttpServletRequest;
import java.util.Calendar;
import java.util.Date;
import java.util.Map;

/**
 * Created by Administrator on 2016/10/27.
 */
public class FreeMarkerViewExtend extends FreeMarkerView{

    protected void exposeHelpers(Map<String, Object> model, HttpServletRequest request){

        try {
            super.exposeHelpers(model, request);
        } catch (Exception e) {
            LoggerUtils.fmtError(FreeMarkerViewExtend.class,e, "FreeMarkerViewExtend 加载父类出现异常。请检查。");
        }
        //String ip = IPUtils.getIP(request);
        //model.put("_time", new Date().getTime());
        //model.put("NOW_YEAY", Calendar.getInstance().get(Calendar.YEAR));//今年

        model.put("_v", GlobalConstant.VersionNumber);//版本号，重启的时间
        model.put("basePath", request.getContextPath());//base目录。

    }

}
